/*
 *  Copyright 2004 Blandware (http://www.blandware.com)
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */
package com.blandware.atleap.service.testimonials;

import com.blandware.atleap.common.util.PartialCollection;
import com.blandware.atleap.common.util.QueryInfo;
import com.blandware.atleap.model.testimonials.Testimonial;
import com.blandware.atleap.persistence.exception.DeleteException;
import com.blandware.atleap.service.core.PageManager;
import com.blandware.atleap.service.exception.BeanAlreadyExistsException;
import com.blandware.atleap.service.exception.BeanNotFoundException;

import java.util.Map;

/**
 * <p>Business Delegate (Proxy) Interface to handle communication between web and
 * persistence layer.
 * </p>
 * <p><a href="TestimonialManager.java.html"><i>View Source</i></a>
 * </p>
 *
 * @author Andrey Grebnev <a href="mailto:andrey.grebnev@blandware.com">&lt;andrey.grebnev@blandware.com&gt;</a>
* @version $Revision: 1.2 $ $Date: 2005/08/02 14:53:43 $
 */
public interface TestimonialManager extends PageManager {

	//~ CRUD Methods ================================================================

	/**
	 * Creates new testimonial item
	 *
	 * @param testimonial      Testimonial item to create
	 * @param linkedObjects Map of pairs <code>uri -&gt; object<code>, which link URI in the body to
	 *                      corresponding object (resource or page) if it exists
	 * @return ID of created testimonial
	 * @throws com.blandware.atleap.service.exception.BeanAlreadyExistsException
	 *          if linkable item with same URI already exists
	 */
	public Long createTestimonial(Testimonial testimonial, Map linkedObjects) throws BeanAlreadyExistsException;

	/**
	 * Retrieves testimonial item with specified ID
	 *
	 * @param testimonialId The ID of testimonial to retrieve
	 * @return Testimonial item or null if no testimonial with specified ID exists in database
	 */
	public Testimonial retrieveTestimonial(Long testimonialId);

	/**
	 * Retrieves lite version (with empty 'title' and 'body' maps) of testimonial item with specified ID
	 *
	 * @param testimonialId ID to search by
	 * @return Testimonial item with specified ID or null if no testimonial with specified ID exists in database
	 */
	public Testimonial retrieveTestimonialLite(Long testimonialId);

	/**
	 * Updates testimonial
	 *
	 * @param testimonial      Testimonial to update
	 * @param linkedObjects Map of pairs <code>uri -&gt; object<code>, which link URI in the body to
	 *                      corresponding object (resource or page) if it exists
	 * @throws com.blandware.atleap.service.exception.BeanAlreadyExistsException
	 *          if page (no matter content or action) with same URI already exists
	 */
	public void updateTestimonial(Testimonial testimonial, Map linkedObjects) throws BeanAlreadyExistsException;

	/**
	 * Updates testimonial without changing links to pages or resources from internal content field values
	 *
	 * @param testimonial      Testimonial to update
	 * @throws com.blandware.atleap.service.exception.BeanAlreadyExistsException
	 *          if page (no matter content or action) with same URI already exists
	 */
	public void updateTestimonial(Testimonial testimonial) throws BeanAlreadyExistsException;

	/**
	 * Removes testimonial
	 *
	 * @param testimonialId ID of testimonial to remove
	 * @throws com.blandware.atleap.persistence.exception.DeleteException
	 *                               if testimonial item cannot be deleted
	 * @throws com.blandware.atleap.service.exception.BeanNotFoundException if testimonial item with specified ID was not found
	 */
	public void deleteTestimonial(Long testimonialId) throws DeleteException, BeanNotFoundException;

	// ~ Additional methods ================================================================

	/**
	 * Retrieves filtered/sorted collection of testimonials
	 *
	 * @param queryInfo Object that contains information about how to filter and sort data
	 * @return Collection of testimonials
	 */
	public PartialCollection listTestimonials(QueryInfo queryInfo);

    /**
     * Retrieves one random active testimonial
     *
     * @return random testimonial or <code>null</code> if there are no active testimonials
     */
	public Testimonial getRandomTestimonial();

}
